<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>产品信息维护</title>
		<script type="text/javascript" src="../../js/jquery-3.2.1.js" ></script>
		<script type="text/javascript" src="../../js/bootstrap.js" ></script>
		<link rel="stylesheet" href="../../css/bootstrap.css" />
		<script type="text/javascript" src="../../js/common.js" ></script>
		<script type="text/javascript" src="../../js/product.js" ></script>
		<link rel="stylesheet" href="../../css/common.css" />
		<style>
			th,
			tbody {
				text-align: center;
			}
		</style>
	</head>

	<body>
		<div class="container">
			<div class="row clearfix">
				<div class="col-md-10 column">
					<button id="open-product-add" 	 type="button" class="btn btn-primary">增加</button>
					<button id="open-product-update" type="button" class="btn btn-warning">修改</button>
					<button id="open-product-delete" type="button" class="btn btn-danger">删除</button>
					<table class="table table-hover table-bordered">
						<thead>
							<tr>
								<th><input type="checkbox" id="check-all"/></th>
								<th>产品名称</th>
								<!--<th>产品类别</th>-->
								<th>产品价格</th>
								<th>产品重量</th>
								<th>公司名称</th>
								<th>公司负责人</th>
							</tr>
						</thead>
						<tbody id="tbody">

						</tbody>
					</table>
				</div>
			</div>
		</div>
		<div class="modal fade" id="error" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
			<div class="alert alert-danger alert-dismissable" id="error-message">
			</div>
		</div>

		<!-- 这是成功的页面，默认隐藏 -->
		<div class="modal fade" id="success" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
			<div class="alert alert-success alert-dismissable" id="success-message">
				
			</div>
		</div>
	</body>
	<script>
		
		//跳转增加页面开始
		$('#open-product-add').click(function(){
			window.location.href="product-add.html";
		});
		//跳转增加页面结束
		
		//跳转修改页面开始
		$('#open-product-update').click(function(){
			var checkList = $('input[type="checkbox"]:checked');
			if(checkList.length == 0){
				$('#error-message').attr('class','alert alert-danger alert-dismissable');
				$('#error-message').html("必须要选中一个..");
				$('#error').modal('show');
				popHide("error");
			}else{
				if(checkList.length == 1){
					if(checkList.val() != 'on'){
						var checkVal = checkList.val();
						window.location.href="product-update.html?id="+checkVal;
					}else{
						$('#error-message').attr('class','alert alert-danger alert-dismissable');
						$('#error-message').html("必须要选中一个..");
						$('#error').modal('show');
						popHide("error");
					}
				}else{
					$('#error-message').attr('class','alert alert-danger alert-dismissable');
					$('#error-message').html("只能选中一个..");
					$('#error').modal('show');
					popHide("error");
				}
				
			}
			//
		});
		//跳转修改页面结束
	</script>
</html>